package com.jt.controller;

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
@RestController
@RequestMapping
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("addUser")
    public String addUser(User user){
        int rows = userService.adduser(user);
        if (rows!=0){
            return "添加成功";
        }
        return "添加失败";
    }
    @RequestMapping("getUser")
    public List<User> getUser (HttpServletResponse response){
//        response.setHeader("Access-Control-Allow-Origin", "*");
//        response.setHeader("Cache-Control","no-cache");
        return userService.getUser();
    }

}
